using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Runtime.CompilerServices;
using ns16;
using ns20;

namespace Newtonsoft.Json.Serialization
{
	public class JsonArrayContract : JsonContainerContract
	{
		private readonly bool bool_7;

		private readonly Type type_3;

		private Type type_4;

		private Delegate3<object, object> delegate3_0;

		private Func<object> func_1;

		[CompilerGenerated]
		private Type type_5;

		[CompilerGenerated]
		private bool bool_8;

		[CompilerGenerated]
		private bool bool_9;

		[CompilerGenerated]
		private bool bool_10;

		[CompilerGenerated]
		private ConstructorInfo constructorInfo_0;

		public Type CollectionItemType
		{
			[CompilerGenerated]
			get
			{
				return type_5;
			}
			[CompilerGenerated]
			private set
			{
				type_5 = value;
			}
		}

		public bool IsMultidimensionalArray
		{
			[CompilerGenerated]
			get
			{
				return bool_8;
			}
			[CompilerGenerated]
			private set
			{
				bool_8 = value;
			}
		}

		internal bool Boolean_0
		{
			[CompilerGenerated]
			get
			{
				return bool_9;
			}
			[CompilerGenerated]
			private set
			{
				bool_9 = value;
			}
		}

		internal bool Boolean_1
		{
			[CompilerGenerated]
			get
			{
				return bool_10;
			}
			[CompilerGenerated]
			private set
			{
				bool_10 = value;
			}
		}

		internal ConstructorInfo ConstructorInfo_0
		{
			[CompilerGenerated]
			get
			{
				return constructorInfo_0;
			}
			[CompilerGenerated]
			private set
			{
				constructorInfo_0 = value;
			}
		}

		public JsonArrayContract(Type underlyingType)
			: base(underlyingType)
		{
			enum15_0 = Enum15.Array;
			bool boolean_;
			Type type;
			if (base.CreatedType.IsArray)
			{
				CollectionItemType = Class195.smethod_18(base.UnderlyingType);
				bool_4 = true;
				type_3 = typeof(List<>).MakeGenericType(CollectionItemType);
				boolean_ = true;
				IsMultidimensionalArray = base.UnderlyingType.IsArray && base.UnderlyingType.GetArrayRank() > 1;
			}
			else if (typeof(IList).IsAssignableFrom(underlyingType))
			{
				if (Class195.smethod_14(underlyingType, typeof(ICollection<>), out type_3))
				{
					CollectionItemType = type_3.GetGenericArguments()[0];
				}
				else
				{
					CollectionItemType = Class195.smethod_18(underlyingType);
				}
				if (underlyingType == typeof(IList))
				{
					base.CreatedType = typeof(List<object>);
				}
				if (CollectionItemType != null)
				{
					ConstructorInfo_0 = Class192.smethod_3(underlyingType, CollectionItemType);
				}
				bool_4 = Class195.smethod_15(underlyingType, typeof(ReadOnlyCollection<>));
				boolean_ = true;
			}
			else if (Class195.smethod_14(underlyingType, typeof(ICollection<>), out type_3))
			{
				CollectionItemType = type_3.GetGenericArguments()[0];
				if (Class195.smethod_12(underlyingType, typeof(ICollection<>)) || Class195.smethod_12(underlyingType, typeof(IList<>)))
				{
					base.CreatedType = typeof(List<>).MakeGenericType(CollectionItemType);
				}
				if (Class195.smethod_12(underlyingType, typeof(ISet<>)))
				{
					base.CreatedType = typeof(HashSet<>).MakeGenericType(CollectionItemType);
				}
				ConstructorInfo_0 = Class192.smethod_3(underlyingType, CollectionItemType);
				boolean_ = true;
				Boolean_0 = true;
			}
			else if (Class195.smethod_14(underlyingType, typeof(IEnumerable<>), out type))
			{
				CollectionItemType = type.GetGenericArguments()[0];
				if (Class195.smethod_12(base.UnderlyingType, typeof(IEnumerable<>)))
				{
					base.CreatedType = typeof(List<>).MakeGenericType(CollectionItemType);
				}
				ConstructorInfo_0 = Class192.smethod_3(underlyingType, CollectionItemType);
				if (underlyingType.smethod_4() && underlyingType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
				{
					type_3 = type;
					bool_4 = false;
					Boolean_0 = false;
					boolean_ = true;
				}
				else
				{
					type_3 = typeof(List<>).MakeGenericType(CollectionItemType);
					bool_4 = true;
					Boolean_0 = true;
					boolean_ = ConstructorInfo_0 != null;
				}
			}
			else
			{
				boolean_ = false;
				Boolean_0 = true;
			}
			Boolean_1 = boolean_;
			if (CollectionItemType != null)
			{
				bool_7 = Class195.smethod_10(CollectionItemType);
			}
		}

		internal Interface15 method_5(object object_0)
		{
			if (delegate3_0 == null)
			{
				type_4 = typeof(Class184<>).MakeGenericType(CollectionItemType);
				Type type = ((Class195.smethod_15(type_3, typeof(List<>)) || type_3.GetGenericTypeDefinition() == typeof(IEnumerable<>)) ? typeof(ICollection<>).MakeGenericType(CollectionItemType) : type_3);
				ConstructorInfo constructor = type_4.GetConstructor(new Type[1] { type });
				delegate3_0 = Class140.Class167_0.ns20_002EClass167_002E_206A_206E_200E_202E_206E_200B_200B_200E_202C_206A_202A_202B_200C_206A_206C_206D_202B_200F_206E_200F_202C_200D_200D_202B_202B_206F_206D_206E_206D_206B_200B_206B_200B_200E_200D_202E_202A_206C_200F_202B_202E<object>(constructor);
			}
			return (Interface15)delegate3_0(null, object_0);
		}

		internal IList method_6()
		{
			if (func_1 == null)
			{
				Type type = (IsMultidimensionalArray ? typeof(object) : CollectionItemType);
				Type type2 = typeof(List<>).MakeGenericType(type);
				func_1 = Class140.Class167_0.ns20_002EClass167_002E_206E_206D_200F_202C_202B_206A_206E_200E_202B_206A_206F_206A_202E_202C_206E_202D_202A_202D_202B_206F_206C_202D_206C_206C_202A_206E_200B_206A_202A_202C_206B_200C_206A_206A_200B_206D_206A_206E_200E_206E_202E<object>(type2);
			}
			return (IList)func_1();
		}
	}
}
